# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Bet4 <0xbet4@gmail.com>

_gemname=elftools
pkgname=ruby-${_gemname}
pkgver=1.2.0
pkgrel=1
pkgdesc='ELF parser library implemented in pure Ruby'
url='https://github.com/david942j/rbelftools/'
arch=('any')
license=('MIT')
depends=('ruby' 'ruby-bindata')
makedepends=('ruby-rake' 'ruby-rdoc' 'ruby-bundler')
options=('!emptydirs')
source=(${url}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz)
sha512sums=('8f5ef2b96f42ab2e06a203fea53bafbd14a08cbd0c60df1ce1fcdd5b4de45c77720f96d1ab551ce9f93ff94a50bb81ad7561c4540379ea4b2c888db446149a5f')
b2sums=('03790ccf38fe1adaf6cf7427ac7cc69f122a72d0bba2005690b2436e2f3806e944ed3bb80b83fe671142f1e56919562c280bb84ebd33e868cdd9ad01b7455959')

prepare() {
  cd rbelftools-${pkgver}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec
}

build() {
  cd rbelftools-${pkgver}
  gem build ${_gemname}.gemspec
}

package() {
  cd rbelftools-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "${pkgdir}${_gemdir}" \
    --bindir "${pkgdir}/usr/bin" \
    ${_gemname}-${pkgver}.gem

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"

  cd "${pkgdir}/${_gemdir}"
  rm -rf cache gems/${_gemname}-${pkgver}/{ext,lib/*/*.so,man} \
    extensions/*/*/${_gemname}-${pkgver}/{mkmf.log,gem_make.out}
}

# vim: ts=2 sw=2 et:
